var imgs = document.getElementsByClassName("real-img");
var modalImg = document.getElementById("insert-img");
var modalBox = document.getElementById("modal-box");
var closeBtn = document.getElementById("close");
var modalTitle = document.getElementById("insert-title");

for (let img of imgs) {
  img.addEventListener('click', function () {
    modalBox.style.display = 'block';
    modalImg.src = this.src;
    modalTitle.innerHTML = this.alt;
  })
}

closeBtn.onclick = function () {
  modalBox.style.display = 'none';
}